package com.zjhn.ds.controller.app.md;

import com.alibaba.fastjson.JSON;
import com.zjhn.ds.common.BizResult;
import com.zjhn.ds.domain.dto.mt.*;
import com.zjhn.ds.domain.dto.pc.SpotCheckDetailDto;
import com.zjhn.ds.param.*;
import com.zjhn.ds.service.AppStationMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @BelongsProject: ds_jlw
 * @BelongsPackage: com.zjhn.ds.controller.app
 * @Author: sxt
 * @CreateTime: 2023-10-08  16:29
 * @Description:
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/jlw/app/monitor")
@Api(tags = "app机台监控接口")
public class AppStationMonitorController {

    @Resource
    private AppStationMonitorService appStationMonitorService;

    @ApiOperation("app机台监控页面数据")
    @PostMapping("/stationMonitor")
    public BizResult<AppStationMonitorV2Dto> stationMonitor(@RequestBody @Valid AppStationMonitorParam param) {
        log.info("====[INFO]========AppStationMonitorController====stationMonitor param:{}", JSON.toJSONString(param));
        return appStationMonitorService.stationMonitor(param);
    }

    @ApiOperation("app获取工位当前刷卡任务")
    @GetMapping("/currentTask")
    public BizResult<CurrentTaskDto> currentTask(@RequestParam("station_id") String stationId) {
        log.info("====[INFO]========AppStationMonitorController====currentTask stationId:{}", stationId);
        return appStationMonitorService.currentTask(stationId);
    }

    @ApiOperation("app获取工位排队任务")
    @GetMapping("/queueTask")
    public BizResult<List<QueueTaskDto>> queueTask(@RequestParam("station_id") String stationId) {
        log.info("====[INFO]========AppStationMonitorController====queueTask stationId:{}", stationId);
        return appStationMonitorService.queueTask(stationId);
    }

    @ApiOperation("app确认报工")
    @PostMapping("/report")
    public BizResult<?> report(@RequestBody @Valid ReportParam param) {
        log.info("====[INFO]========AppStationMonitorController====report param:{}", JSON.toJSONString(param));
        return appStationMonitorService.report(param);
    }

    @ApiOperation("app刷卡")
    @PostMapping("/swipeCard")
    public BizResult<?> swipeCard(@RequestBody @Valid SwipeCardParam param) {
        log.info("====[INFO]========AppStationMonitorController====swipeCard param:{}", JSON.toJSONString(param));
        return appStationMonitorService.swipeCard(param);
    }

    @ApiOperation("app派工任务完成")
    @PostMapping("/finishTask")
    public BizResult<?> finishTask(@RequestBody @Valid FinishTaskParam param) {
        log.info("====[INFO]========AppStationMonitorController====finishTask param:{}", JSON.toJSONString(param));
        return appStationMonitorService.finishTask(param);
    }

    @ApiOperation("app抽查")
    @PostMapping("/spotCheck")
    public BizResult<?> spotCheck(@RequestBody @Valid SpotCheckParam param) {
        log.info("====[INFO]========AppStationMonitorController====spotCheck param:{}", JSON.toJSONString(param));
        return appStationMonitorService.spotCheck(param);
    }

    @ApiOperation("app抽检扫码获取工位当前刷卡任务")
    @GetMapping("/spotCheckCurrentTask")
    public BizResult<SpotCurrentTaskDto> spotCheckCurrentTask(@RequestParam("station_code") String stationCode) {
        log.info("====[INFO]========AppStationMonitorController====spotCheckCurrentTask stationCode:{}", stationCode);
        return appStationMonitorService.spotCheckCurrentTask(stationCode);
    }

    @ApiOperation("app机台历史抽查记录")
    @GetMapping("/spotCheckHistory")
    public BizResult<List<SpotCheckDetailDto>> spotCheckHistory(@RequestParam("station_code") String stationCode) {
        log.info("====[INFO]========AppStationMonitorController====spotCheckHistory stationCode:{}", stationCode);
        return appStationMonitorService.spotCheckHistory(stationCode);
    }

    @ApiOperation("app开始改机")
    @PostMapping("/machineChange")
    public BizResult<?> machineChange(@RequestBody MaintenanceChangeParam param) {
        log.info("====[INFO]========AppStationMonitorController====machineChange param:{}", JSON.toJSONString(param));
        return appStationMonitorService.machineChange(param);
    }

    @ApiOperation("app改机结束")
    @PostMapping("/machineChangeFinish")
    public BizResult<?> machineChangeFinish(@RequestBody MachineChangeFinishParam param) {
        log.info("====[INFO]========AppStationMonitorController====machineChangeFinish param:{}", JSON.toJSONString(param));
        return appStationMonitorService.machineChangeFinish(param);
    }

    @ApiOperation("app开始维修")
    @PostMapping("/maintenance")
    public BizResult<?> maintenance(@RequestBody MaintenanceChangeParam param) {
        log.info("====[INFO]========AppStationMonitorController====maintenance param:{}", JSON.toJSONString(param));
        return appStationMonitorService.maintenance(param);
    }

    @ApiOperation("app维修结束")
    @PostMapping("/maintenanceFinish")
    public BizResult<?> maintenanceFinish(@RequestParam("maintenance_id") String maintenanceId) {
        log.info("====[INFO]========AppStationMonitorController====maintenanceFinish maintenanceId:{}", maintenanceId);
        return appStationMonitorService.maintenanceFinish(maintenanceId);
    }

    @ApiOperation("app开始编织打样")
    @PostMapping("/proofing")
    public BizResult<?> proofing(@RequestBody ProofingParam param) {
        log.info("====[INFO]========AppStationMonitorController====proofing param:{}", JSON.toJSONString(param));
        return appStationMonitorService.proofing(param);
    }

    @ApiOperation("app编织打样结束")
    @PostMapping("/proofingFinish")
    public BizResult<?> proofingFinish(@RequestParam("proofing_id") String proofingId) {
        log.info("====[INFO]========AppStationMonitorController====proofingFinish proofingId:{}", proofingId);
        return appStationMonitorService.proofingFinish(proofingId);
    }

}
